package com.foxchen.offline.task.mapper;

import com.foxchen.offline.task.bean.TaskPojo;
import com.foxchen.offline.task.dto.TaskInfoDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OfflineTaskMapper {
    int insert(TaskPojo taskPojo);

    @Delete("delete from offline_task where id = #{id}")
    int deleteById(String id);

    List<TaskPojo> list(TaskInfoDto taskInfo);

    @Update("update offline_task set status = #{pojo.status},progress = #{pojo.progress},file_id = #{pojo.fileId}," +
            "file_name = #{pojo.fileName} , file_path = #{pojo.filePath} , file_suffix = #{pojo.fileSuffix} , " +
            "gmt_modified = #{pojo.gmtModified} where id = #{pojo.id}"
    )
    int updateById(@Param("pojo") TaskPojo taskPojo);

    @Select("select * from offline_task where status = '-1' or status = '0'")
    List<TaskPojo> selectUnBeginTask();

    @Select("select * from offline_task where id = #{id}")
    TaskPojo getById(@Param("id") String id);
}
